﻿
@{
    ViewBag.Title = "标片编辑";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
@model IOA.MES.DataAccess.VModel.VStandardPiece

@section Contents{
    <style>
        html {
            background-color: #FFF;
        }

        .layui-form-item .layui-input-inline {
            width: 300px;
        }

        .red {
            color: red;
        }
    </style>
}

<div id="page"></div>

<script type="text/template" id="tplPage">
    <div class="layui-form" lay-filter="layuiadmin-app-form-list" style="padding: 20px 30px;">
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>{{lang.Field.StandardTabletCode}}：</label>
            <div class="layui-input-inline">
                <input type="text" lay-verify="required" class="layui-input" name="ProductCode" value="@(Model==null?"":Model.ProductCode)">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>{{lang.Field.StandardTabletModule}}：</label>
            <div class="layui-input-inline">
                <input type="text" lay-verify="required" class="layui-input" name="Model" value="@(Model==null?"":Model.Model)">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>Pmax：</label>
            <div class="layui-input-inline" style="width:100px;">
                <input type="text" lay-verify="required" name="Pmax" value="@(Model == null ? "" : Model.Pmax.ToString())" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">-</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="PmaxToleranceDown" value="@(Model==null?"":Model.PmaxToleranceDown.ToString())">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">+</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="PmaxToleranceUp" value="@(Model==null?"":Model.PmaxToleranceUp.ToString())">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>Voc：</label>
            <div class="layui-input-inline" style="width:100px;">
                <input type="text" lay-verify="required" name="Voc" value="@(Model == null ? "" : Model.Voc.ToString())" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">-</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="VocToleranceDown" value="@(Model==null?"":Model.VocToleranceDown.ToString())">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">+</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="VocToleranceUp" value="@(Model==null?"":Model.VocToleranceUp.ToString())">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>Isc：</label>
            <div class="layui-input-inline" style="width:100px;">
                <input type="text" lay-verify="required" name="Isc" value="@(Model == null ? string.Empty : Model.Isc.ToString())" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">-</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="IscToleranceDown" value="@(Model==null?"":Model.IscToleranceDown.ToString())">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">+</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="IscToleranceUp" value="@(Model==null?"":Model.IscToleranceUp.ToString())">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>Vmp：</label>
            <div class="layui-input-inline" style="width:100px;">
                <input type="text" lay-verify="required" name="Vmp" value="@(Model == null ? string.Empty : Model.Vmp.ToString())" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">-</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="VmpToleranceDown" value="@(Model==null?"":Model.VmpToleranceDown.ToString())">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">+</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="VmpToleranceUp" value="@(Model==null?"":Model.VmpToleranceUp.ToString())">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>Imp：</label>
            <div class="layui-input-inline" style="width:100px;">
                <input type="text" lay-verify="required" name="Imp" value="@(Model == null ? string.Empty : Model.Imp.ToString())" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">-</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="ImpToleranceDown" value="@(Model==null?"":Model.ImpToleranceDown.ToString())">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">+</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="ImpToleranceUp" value="@(Model==null?"":Model.ImpToleranceUp.ToString())">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>FF：</label>
            <div class="layui-input-inline" style="width:100px;">
                <input type="text" lay-verify="required" name="FF" value="@(Model == null ? string.Empty : Model.FF.ToString())" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">-</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="FFToleranceDown" value="@(Model==null?"":Model.FFToleranceDown.ToString())">
            </div>
            <div class="layui-input-inline" style="width:10px;line-height:38px;text-align:center;">+</div>
            <div class="layui-input-inline" style="width:70px;">
                <input type="text" lay-verify="required" class="layui-input" name="FFToleranceUp" value="@(Model==null?"":Model.FFToleranceUp.ToString())">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"><span class="red">*</span>{{lang.Field.PeriodOfValidity}}：</label>
            <div class="layui-input-inline">
                <input type="text" lay-verify="required" name="RangeDate" id="txtRangeDate" value="@(Model==null?"":$"{Model.StartDate.ToString("yyyy-MM-dd")} 至 {Model.EndDate.ToString("yyyy-MM-dd")}")" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" style="text-align:center;padding-top: 20px;">
            <input type="hidden" name="PkId" value="@(Model==null?0:Model.PkId)" />
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="submit"><i class="layui-icon">&#xe605;</i>{{lang.Field.Submit}}</button>
            <button class="layui-btn layui-btn-primary" onclick="parent.layer.close(parent.layer.getFrameIndex(window.name));"><i class="layui-icon">&#xe616;</i>{{lang.Field.Cancel}}</button>
        </div>
    </div>
</script>

@section Scripts{
    <script>
        var vm = new Vue({
            el: "#page",
            template: "#tplPage",
            data: {
                lang: JSON.parse(lang).package
            }
        });
        setTimeout(function () {
            initLayui();
        }, 50);
        function initLayui() {
            layui.use(['form', 'layer', 'index', 'laydate'], function () {
                var layer = layui.layer,
                    form = layui.form,
                    laydate = layui.laydate;

                laydate.render({
                    elem: '#txtRangeDate'
                    , range: '至'
                    , trigger: 'click'
                });

                form.on('submit(submit)', function (data) {
                    console.log(data.field);
                    var forms = data.field;
                    var rangeTime = $("#txtRangeDate").val().trim() == '' ? new Array() : $("#txtRangeDate").val().trim().split(' 至 ');
                    forms.StartDate = rangeTime.length <= 0 ? null : rangeTime[0];
                    forms.EndDate = rangeTime.length <= 0 ? null : rangeTime[1];
                    if (forms.StartDate == null || forms.EndDate == "") {
                        layer.msg("请填写有效期", { icon: 5 });
                        return;
                    }
                    var loadId = layer.load();
                    $.ajax({
                        url: "/ParaSetting/EditStandardPiece",
                        data: {
                            model: forms
                        },
                        complete: function () {
                            layer.close(loadId);
                        },
                        success: function (res) {
                            if (res.ErrCode != 200) {
                                layer.msg(res.ErrMsg, { icon: 5 });
                                return;
                            }
                            layer.msg("保存成功！", { icon: 6, time: 1500 }, function () {
                                parent.layer.close(parent.layer.getFrameIndex(window.name));
                            });
                        }
                    });
                    return false;
                });
            });
        }
    </script>
}
